#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
vector<int> a;
vector<int> b;    
int n, m;
int check(int x) {
    int ans = 0;
    for(auto s : a) {
        if(x < s) {
            ans += (s - x);
        }
    }
    if(ans > m) {
        return 1;
    }else if(ans == m) {
        return 0;
    }else {
        return -1;
    }
}
signed main() {

    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());
    int Max = a[n - 1];
    int l = a[0], r = Max;
    int ret = 0;
    while(l <= r) {
        int mid = l + (r - l)/2;
        if(check(mid) == 1) {
            l = mid + 1;
            ret = mid;
        }else if(check(mid) == 0) {
            cout << mid << endl;
            return 0;
        }else {
            r = mid - 1;  
        }
    }
    cout << ret << endl;
    return 0;
}